<?php

namespace App\Http\Controllers\Admin;

use App\Http\Requests\ChangePasswordRequest;
use App\Repositories\LoginLogRepository;
use App\Repositories\UserRepository;
use App\Utils\Auth;

class IndexController extends BaseController
{
    function __construct()
    {
        $this->set('index');
    }

    function index()
    {
        return $this->view('welcome');
    }

    function profile(LoginLogRepository $rep)
    {
        $page = $rep->adminPager(['user_id' => Auth::userId()]);
        return $this->view('profile')->with('page',$page);
    }

    function changePassword(ChangePasswordRequest $request, UserRepository $repository)
    {
        return $repository->changePassword(Auth::userId(), $request->get('old'), $request->get('password'));
    }

    function changePasswordView()
    {
        return $this->view('changePassword');
    }
}
